package com.asiainfo.sqlextractor.functions;

import com.google.common.collect.ImmutableList;
import org.apache.calcite.sql.SqlOperator;
import org.apache.calcite.sql.SqlOperatorTable;
import org.apache.calcite.sql.util.ChainedSqlOperatorTable;
import org.apache.calcite.sql.util.ListSqlOperatorTable;

import static com.asiainfo.sqlextractor.functions.StandardConvertletTableExt.createSqlFunction;


public class MemSqlOperatorTable extends ChainedSqlOperatorTable {

    private final ListSqlOperatorTable listOpTab;

    public MemSqlOperatorTable(SqlOperatorTable parentTable) {
        super(ImmutableList.of(parentTable, new ListSqlOperatorTable()));
        listOpTab = (ListSqlOperatorTable) tableList.get(1);
    }

    public void addOperator(SqlOperator op) {
        listOpTab.add(op);
    }

    public static void registerFunctions(MemSqlOperatorTable opTab) {
        opTab.addOperator(createSqlFunction("CALL_FUNC"));
        opTab.addOperator(createSqlFunction("CALL_API"));
        opTab.addOperator(createSqlFunction("CALL_SCRIPT"));
    }

}
